{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "collapsed_sections": [
        "Jx8XFw6W9PsU",
        "-Dl4dJzbCRP0"
      ]
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "id": "gM7EZczY8ZAX"
      },
      "outputs": [],
      "source": [
        "%%capture --no-stderr\n",
        "%pip install --quiet -U langgraph"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [],
      "metadata": {
        "id": "YTK1e3FB9Rap"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Case 0 - Basic Usage\n",
        "\n",
        "https://langchain-ai.github.io/langgraph/how-tos/human_in_the_loop/wait-user-input/#simple-usage"
      ],
      "metadata": {
        "id": "Jx8XFw6W9PsU"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from typing_extensions import TypedDict\n",
        "from langgraph.graph import StateGraph, START, END\n",
        "from langgraph.checkpoint.memory import MemorySaver\n",
        "from IPython.display import Image, display\n",
        "\n",
        "from langgraph.types import Command, interrupt\n",
        "\n",
        "\n",
        "class State(TypedDict):\n",
        "    input: str\n",
        "    user_feedback: str\n",
        "\n",
        "\n",
        "def step_1(state):\n",
        "    print(\"---Step 1---\")\n",
        "    pass\n",
        "\n",
        "\n",
        "def human_feedback(state):\n",
        "    print(\"---human_feedback---\")\n",
        "\n",
        "    feedback = interrupt({\"Please provide feedback:\": \"WAITING to Start\"})\n",
        "\n",
        "    print(\"\\n\\n[GOT BACK FROM HUMAN AFTER INTERRUPT:]\\n\\n\", feedback)\n",
        "    return {\"user_feedback\": feedback}\n",
        "\n",
        "\n",
        "def step_3(state):\n",
        "    print(\"---Step 3---\")\n",
        "    pass\n",
        "\n",
        "\n",
        "builder = StateGraph(State)\n",
        "builder.add_node(\"step_1\", step_1)\n",
        "builder.add_node(\"human_feedback\", human_feedback)\n",
        "builder.add_node(\"step_3\", step_3)\n",
        "\n",
        "builder.add_edge(START, \"step_1\")\n",
        "builder.add_edge(\"step_1\", \"human_feedback\")\n",
        "builder.add_edge(\"human_feedback\", \"step_3\")\n",
        "builder.add_edge(\"step_3\", END)\n",
        "\n",
        "# Set up memory\n",
        "memory = MemorySaver()\n",
        "\n",
        "# Add\n",
        "graph = builder.compile(checkpointer=memory)\n",
        "\n",
        "# View\n",
        "display(Image(graph.get_graph().draw_mermaid_png()))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 449
        },
        "id": "TJsHcyyJ9-V5",
        "outputId": "03a0a933-e618-4d37-8bd9-e23768243179"
      },
      "execution_count": 5,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKgAAAGwCAIAAACy27mhAAAAAXNSR0IArs4c6QAAIABJREFUeJztnXdcFEf/+Od67xz1aGqsgKBgIYCgYhRBgxIlNmLUqDEa0yx51PgkPzSJiRpFjQZLYom9Yqwxxi7WaCwIiIog9Xqvvz/O7z1ED8R4d7PH7PvFH7C3u/NZ3je7s7OfnSHYbDaAgx5E2AHgwAEXjyi4eETBxSMKLh5RcPGIQoYdQFNUP9JplVatymw22Qw6K+xwmgWNQaRQiUwuickh+QbTYYfTKFgUX3xddf+GpuyWJrQD02K2MTlkoR8VeEl3g9UMnlTqtEoLlUEsv6sNj2C1imSFR7Bhx/UsBEx14NwpVJ47UB/cjhHWkRXeiUWhefeVSKexlP2tqSzVPSnTx2eIWkdhSD9WxCvqTEc3Vgn8qPEZIiYHi+ehV0Feazx3oN5qtfUb7U/FxrcZE+JLb6jP7q8bNDGQL6bCjsWN1DzW71leMWhSYEA4A3YsGBBfUaL765Q87d0AuGF4jJ0/PO6d7Sv0g/wVhyz+77OKB3c06eMDIcbgeXb+8LhrX0F4JxbEGGBeb56U6e5eVqFmHQCQ9aHkz521KpkJYgzQxBv11sLD0qwPJbACgMuIWcG/b62BGAA08W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D/3ChUGuyJ/4pLrk+eV8rp9cWf38cg5bNPPD7Y3tTa82CvyocK3Dr/EAgBtnFLcu6QPaN5qHKpVVOl1uNpvIZCfXCCqV4bgXdwkKZa3F4qTF11gARCKJz2s0zab8elXiIF5YJ8jZpPCfjEUl8C4fkxm1JirT+ZVeKAj0eFD/wN795xI0Mj2FaoNuHf7TOTu9s8WKJ5hISHI36mpl6tsu+xq9CpgQH9aBFdqWUlsKPy/FrVTerumcwBIFYiKNGBPiAQDd+gl5AltNqYc6zjxP5Z3asHbU9nFc2IE8BX7jriEnttfV19rErYSwA3ExT+7WtYumd0nBUIYZtsQDAM4flD4sNvqEC8lQn2G4CqPWVH2vLup1TuckDFnHongAQOlNzfEt1fwAtm8boXe9J9sQi9laUyzVKXQDxvoHwO6gfR4sirdz+Zjs1kUViUrhiJkcXxaR6B3fAIvJoqzVqmu1FqOpS29+VAK2KroD7IoHAFittuJr6ruX1U/u6yg0EplGIlFJFCbVasLWDJEkCsmoMVpMFqvZatCag9sx28eyW0fBv1lvAkyLb4i02qhVmjVKi9lgNZmwFTOFRqRQCSwumcklCXy9Y2pyrxGP41qwch+P42Fw8YiCi0cUXDyi4OIRBRePKP8fSoQ0dZ5Pi8MAAAAASUVORK5CYII=\n",
            "text/plain": [
              "<IPython.core.display.Image object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Input\n",
        "initial_input = {\"input\": \"hello we are learning interrupt\"}\n",
        "\n",
        "# Thread\n",
        "thread = {\"configurable\": {\"thread_id\": \"1\"}}\n",
        "\n",
        "# Run the graph until the first interruption\n",
        "for event in graph.stream(initial_input, thread, stream_mode=\"updates\"):\n",
        "    print(event)\n",
        "    print(\"\\n\")\n",
        "\n",
        "# State Get\n",
        "# State Update\n",
        "# Continue"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "svOfCDHa_I-6",
        "outputId": "85fa1878-bddf-4b1b-fc3d-0db7f48e7064"
      },
      "execution_count": 6,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "---Step 1---\n",
            "{'step_1': None}\n",
            "\n",
            "\n",
            "---human_feedback---\n",
            "{'__interrupt__': (Interrupt(value={'Please provide feedback:': 'WAITING to Start'}, resumable=True, ns=['human_feedback:c5a533e6-2178-56c8-ab0a-a7322318bd35'], when='during'),)}\n",
            "\n",
            "\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# HOW TO RESUME\n",
        "# Continue the graph execution\n",
        "for event in graph.stream(\n",
        "    Command(resume=\"Requesting to Start\"),\n",
        "    thread,\n",
        "    stream_mode=\"updates\"\n",
        "):\n",
        "    print(event)\n",
        "    print(\"\\n\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "rksqtSwiAKLt",
        "outputId": "88806a89-ecbf-474f-b9de-9c2120c576c9"
      },
      "execution_count": 7,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "---human_feedback---\n",
            "\n",
            "\n",
            "[GOT BACK FROM HUMAN AFTER INTERRUPT:]\n",
            "\n",
            " Requesting to Start\n",
            "{'human_feedback': {'user_feedback': 'Requesting to Start'}}\n",
            "\n",
            "\n",
            "---Step 3---\n",
            "{'step_3': None}\n",
            "\n",
            "\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Case 1: Approve or Reject\n",
        "\n",
        "![image.png]()"
      ],
      "metadata": {
        "id": "-Dl4dJzbCRP0"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from typing_extensions import TypedDict\n",
        "from typing import Literal\n",
        "from langgraph.graph import StateGraph, START, END\n",
        "from langgraph.checkpoint.memory import MemorySaver\n",
        "from IPython.display import Image, display\n",
        "\n",
        "from langgraph.types import Command, interrupt\n",
        "\n",
        "\n",
        "class State(TypedDict):\n",
        "    input: str\n",
        "\n",
        "def human_approval(state) -> Command[Literal[\"__end__\", \"call_agent\"]]:\n",
        "    print(\"---human_feedback---\")\n",
        "\n",
        "    is_approved = interrupt(\"Is this correct?\")\n",
        "\n",
        "    print(\"\\n\\n[RESUME AFTER INTERRUPT:]\\n\\n\", is_approved)\n",
        "\n",
        "    if is_approved == \"yes\":\n",
        "        return Command(goto=\"call_agent\")\n",
        "    else:\n",
        "        return Command(goto=\"__end__\")\n",
        "\n",
        "\n",
        "def call_agent(state):\n",
        "    print(\"---call_agent 3---\")\n",
        "    pass\n",
        "\n",
        "\n",
        "builder = StateGraph(State)\n",
        "builder.add_node(\"human_approval\", human_approval)\n",
        "builder.add_node(\"call_agent\", call_agent)\n",
        "\n",
        "builder.add_edge(START, \"human_approval\")\n",
        "\n",
        "# Set up memory\n",
        "memory = MemorySaver()\n",
        "\n",
        "# Add\n",
        "graph = builder.compile(checkpointer=memory)\n",
        "\n",
        "# View\n",
        "display(Image(graph.get_graph().draw_mermaid_png()))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 266
        },
        "id": "iXXo9tEPCFGZ",
        "outputId": "a22cc395-ac8e-427a-a1ed-4b044d815732"
      },
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQQAAAD5CAIAAABOEdwuAAAAAXNSR0IArs4c6QAAIABJREFUeJzt3WdAU2ffBvB/FiQQ9h4CgiAyFBW0aq2i4ECGtYpaFLXaqrVWqz5PW7XV1m1bx1NHh9a6cWuxKg4UUVFRixW3oiIgIyEkJCE774fkpWoDCgbuE/L/fYKMkwuSK/c5Jyf3oWm1WkAIAdBJB0CIKrAMCOlhGRDSwzIgpIdlQEgPy4CQHpN0AOqqEasqS5XSapVUpFartCqVCeyDptGAaUGztmFa2TJsnVi2jizSiUwJDT9neImwUvkwT1xwQ6KUayyt6FY2TCtbBteOqVKYwD+KxgC5RCOpVklFahoN5FJN63DrgPbWTh6WpKOZACzDPxQyzYXDvGqBytHNwj/c2qM1h3SiN1VeJHt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1cKpEkxA/RLfzKlYv3H9x5f+RYALC1sXVxcTtz5kROTrZMLtOtlb0OeY3m0Y3qDu8Y2AdleK7VyxmVChl06O3476vM0JXjPHtnZsdoak23ev4PHoPFDO1OrVT1U6vVDAYDABQKxc+//u/gwd0ZRy808y5BUaXy1PaS1LkGPpowTo6EpN4GLw9p1/7W7b//fbmtjd32bYeM8tA6n06f8OjRg39f7uLiVlFR1gwBzMrFi+cWLZlr8Ko1/9vk69va4FXHj/+54be10b37eXh4CQT87OxMPz9/Su0cN06UX37eYfgKLYCh6UDpNCNvuH89d4lSZWCrWqVUMg2t3Ro9gFmJiIis6xl3ca5zsmpfP//wsIiTp46KREInJ+ce3XuNSqHWGVyNUwbi+/51H2Oj5sFmsxvxjLcNavfV3MVNk8g48A0SIT0sA0J6WAaE9LAMCOlhGRDSwzIgpIdlQEgPy4CQHpYBIT0sA0J6hg/HsGDTNAYPKjJLlhwG04Jy/w1LDgPo+F7WYHQazdHD8PHnhv+bNg6siifGnKvMpJU+ktq7GP4uC0Fce0bFU3yOGoz/TFbXueQNl8G1lSWNcm+FxNAZ4NqqkfOmNB2XVpZaDZ4HusGqBUrvtoa/tVbnyODVhn12X2kTBzMBmTtLgjrZWHIYpIO8zMnd0tnL4kK6gW9roLoU3hEX3ha372H4G1GGv+mmczNHeD9P3KGXk4ObBYNpXqunSoWmqkJ+7SS/Q0+7wI42pOPUKS+r6uk9aWgPRyd3SzoDR/M6VVUoygulD69XD5vmTatjPam+MgDAo5uSvKyq0kcyBtOM/tFMFl0hU3sHciJ623sHNuG3q43iwXXx9SwBv1QJuNJUB2dPS6lYFdTJpkv/+r7J/Ioy1JLXNHJWKdOkpeB60SuZ2XPUAHQGjfUa+wNftwwItXjmtSWAUD2wDAjpYRkQ0sMyIKSHZUBID8uAkN7/AdFAeCO+bYH9AAAAAElFTkSuQmCC\n",
            "text/plain": [
              "<IPython.core.display.Image object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Input\n",
        "initial_input = {\"input\": \"hello from UMT Lahore\"}\n",
        "\n",
        "# Thread\n",
        "thread = {\"configurable\": {\"thread_id\": \"11122232\"}}\n",
        "\n",
        "# Run the graph until the first interruption\n",
        "for event in graph.stream(initial_input, thread, stream_mode=\"updates\"):\n",
        "    print(event)\n",
        "    print(\"\\n\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "QyBu8fsQ1hit",
        "outputId": "cd83bbf1-6cf9-4e2d-ac7d-12f00f4afb39"
      },
      "execution_count": 11,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "---human_feedback---\n",
            "{'__interrupt__': (Interrupt(value='Is this correct?', resumable=True, ns=['human_approval:3002955b-02a9-5b8c-eb9f-5ec60985fefc'], when='during'),)}\n",
            "\n",
            "\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# HOW TO RESUME\n",
        "# Continue the graph execution\n",
        "for event in graph.stream(\n",
        "    Command(resume={\"\": \"\"}),\n",
        "    thread,\n",
        "    stream_mode=\"updates\"\n",
        "):\n",
        "    print(event)\n",
        "    print(\"\\n\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "aYxZd9td1jse",
        "outputId": "ae061d27-84e4-4d1a-a47e-e08040bb0f8c"
      },
      "execution_count": 12,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "---human_feedback---\n",
            "\n",
            "\n",
            "[RESUME AFTER INTERRUPT:]\n",
            "\n",
            " none\n",
            "{'human_approval': None}\n",
            "\n",
            "\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Case 2 Tool Calling - Review/Reject\n",
        "\n",
        "https://langchain-ai.github.io/langgraph/concepts/human_in_the_loop/#review-tool-calls"
      ],
      "metadata": {
        "id": "A_VfyraKg_pK"
      }
    },
    {
      "cell_type": "code",
      "source": [],
      "metadata": {
        "id": "fnvLfWl1hAPw"
      },
      "execution_count": null,
      "outputs": []
    }
  ]
}